Skip to content

Add default network timeouts to Client - #23

Merged
eberquist merged 1 commit into
masterfrom
add-client-timeouts
Nov 23, 2026
Merged

eberquist merged 1 commit into
masterfrom
add-client-timeouts

Conversation

@eberquist

Copy link
Copy Markdown
Contributor

Client never passed a timeout to requests, which has no default, so a stalled connection could make verify, batch, batch_status and account hang forever. The timeout argument to verify doesn't help here: it only tells the API how long to spend verifying, not how long to wait on the network.

Changes

  • Every request now uses a 30s connect timeout and a 60s read timeout, the same defaults as emailable-ruby. The read timeout is longer than the server-side timeout that verify accepts.
  • Both are class attributes and can be changed globally or per client:
    emailable.Client.open_timeout = 10
    emailable.Client.read_timeout = 45
  • Setting either one to None raises ValueError, because requests treats None as "wait forever." Other invalid values (strings, booleans, zero, negative numbers) are already rejected by requests.
  • When no response comes back (a timeout, refused connection, DNS failure, etc.), the ClientError message now contains the underlying error text, e.g. ClientError(None, 'read timed out'), instead of None. The exception type and status_code are unchanged.
  • Documented both timeouts in the README, including how they differ from verify's timeout.

Testing

  • New tests/test_timeout.py checks the default and custom timeouts, the separation from verify's timeout, the None check, the error message on a timeout. It doesn't make any network calls.
  • The existing test suite passes against the hosted API.

Copilot AI balanced review requested due to automatic review settings November 23, 2026 16:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approved

No active review issues were identified in the configurable client network timeout changes.

No open issues 🎉

What changed in this PR

Adds default network timeouts to the shared Client request handling, separate from verify’s server-side timeout.

Changes:

  • Apply configurable 30-second connect and 60-second read timeouts to all client requests.
  • Reject None timeout values and include underlying network error messages in ClientError.
  • Document timeout behavior and add mocked tests for defaults, configuration, validation, and failures.
File Description
tests/​test_timeout.py Tests network timeout settings, validation, and error handling without network calls.
README.md Documents timeout defaults, configuration, and the distinction from verification timeouts.
emailable/​client.py Applies timeout defaults, rejects None, and preserves network error text.

Review effort: Balanced

@eberquist
eberquist merged commit 7245a7f into master Nov 23, 2026
5 checks passed
@eberquist
eberquist deleted the add-client-timeouts branch November 23, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants